﻿@model Easy.Web.CMS.Widget.WidgetBase
@{
    Script.Reqiured("validate").AtFoot();
}
<div class="panel panel-default">
    <div class="panel-heading">
        <div>
            @ViewBag.WidgetTemplateName
        </div>
    </div>
    <div class="panel-body">
        @using (Html.BeginForm())
        {
            @Html.EditorForModel()
            <input type="hidden" name="ReturnUrl" value="@ViewBag.ReturnUrl" />
            <div class="toolBar">
                <input id="design" type="submit" class="btn btn-primary" value="保存" data-value="@ActionType.Update" />
                @if (Model.IsTemplate && Model.Thumbnail.IsNotNullAndWhiteSpace())
                {
                    <a href="@Url.Action("Pack", new {Model.ID})" class="btn btn-success">
                        <i class="glyphicon glyphicon-save-file"></i>
                        打包模板
                    </a>
                }
                <input id="copy-widget" type="button" class="btn btn-warning" data-id="@Model.ID" value="复制" />
                <input type="button" class="btn btn-default cancel" value="取消" />
            </div>
        }
    </div>
</div>
@using (Script.AtFoot())
{
    <script type="text/javascript">
        $(function () {
            $(document).on("click", "#copy-widget", function () {
                $.post("@Url.Action("Copy","Widget",new{module="admin"})", { widgetId: $(this).data("id") }, function (data) {
                    Easy.MessageTip.Show(data.Message);
                });
            });
        });
    </script>
}